package util;

import ds.bPlusTree.BPlusTree;
import ds.linearHsh.LinearHashMap;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.stream.Stream;

public class TxtReader {
    public static void readLine(int line) throws IOException {
        String filePath = System.getProperty("user.dir") + "/db/primary/product.txt";
        LinearHashMap lhm = new LinearHashMap();
        BPlusTree bt = new BPlusTree();
        try(Stream<String> lines = Files.lines(Paths.get(filePath))){
            lines.forEach(str ->{
                if(!str.equals("#productId#productName#category#cost#price#deposit#unit")){
                    String[] cols = str.split("#");
//                    lhm.add(Integer.valueOf(cols[0]));
                    bt.insert(Integer.valueOf(cols[0]),cols[1]);
                }
//                if(cols[0].equals("" + line))
//                    System.out.println(str);
            });
        }
        String s = bt.search(3);
//        lhm.search(2);
//        lhm.displayAll();
    }
}
